import * as actionTypes from "./actionTypes";
import { getshopCates } from '../../../../apis/shop'
export const setCates = (data) => {
    return {
        type: actionTypes.ShopCates,
        data: data,
    }
}
//页面初始化
export const getCates = () => {
    return (dispatch) => {
        getshopCates().then(res => {
            let data = res.data ? res.data.map(v => {
                return {
                    ...v,
                    title: v.name.split('').length > 5 ? v.name.split('').slice(0, 4).join('') + '...' : v.name
                }
            }) : []
            dispatch(setCates(data))
        })
    }
}
